package org.dormi.learn.usermodule;

import org.dormi.learn.daomodule.Dao;
import org.dormi.learn.entitymodule.User;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author : dormi330
 * @since : 2021/1/25/0025
 */
public class UserDao implements Dao<User> {

    private static Map<Integer, User> users = new HashMap<>(3);

    @Override
    public void add(Integer id, User user) {
        users.put(id, user);
    }

    @Override
    public User findById(int id) {
        return users.get(id);
    }

    @Override
    public List<User> listAll() {
        return new ArrayList<>(users.values());
    }
}
